import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as shoppingCartActions from '../../actions/shoppingCart'
import * as orderActions from '../../actions/order'

export function connectShoppingCart(Component) {
	class WrapComp extends React.Component {
		render() {
			return (
				<div><Component {...this.props} /></div>
			);
		}
	}
	 const mapStateToProps = (state) => ({
   		shoppingCart: {
   			goodsData: state.shoppingCart.goodsData,
   			isFetched: state.shoppingCart.isFetched,
   			isCleaned: state.shoppingCart.isCleaned,
   			isDeleted: state.shoppingCart.isDeleted,
   			isAdded: state.shoppingCart.isAdded,
   		},
   		order: {
		    isPreviewed: state.order.isPreviewed,
		    orderPreview: state.order.orderPreview,
   		}
  	});
  	const mapDispatchToProps = (dispatch) => ({
		shoppingCartActions: bindActionCreators(shoppingCartActions, dispatch),
		orderActions: bindActionCreators(orderActions, dispatch)
  	});
	return connect(mapStateToProps, mapDispatchToProps)(WrapComp);
}